package com.taxshare.seller.controller;

import com.taxshare.mybatis.pager.PageRequest;
import com.taxshare.pvalidate.ParamValid;
import com.taxshare.response.beans.Response;
import com.taxshare.seller.service.EstateGoodsManageService;
import com.taxshare.seller.view.dto.EstateGoodsManageDTO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.util.List;

/**
 * @ClassName: EstateGoodsManageController
 * @Description:
 * @author: hjh
 * @date: 2021/5/27 17:29
 */
@RestController
@RequestMapping("/estateGoodsManage")
@Api(tags = "地产商品管理")
public class EstateGoodsManageController {

    @Autowired
    EstateGoodsManageService EstateGoodsManageService;

    @PostMapping("/add")
    @ApiOperation(value = "地产商品管理新增", notes = "地产商品管理")
    @ParamValid
    public Response estateGoodsManageAdd(@RequestBody @Valid EstateGoodsManageDTO estateGoodsManageDTO) {
        return EstateGoodsManageService.EstateGoodsManageAdd(estateGoodsManageDTO);
    }

    @PostMapping("/remove")
    @ApiOperation(value = "地产商品管理删除", notes = "地产商品管理")
    public Response goodsManageRemove(@RequestBody List<String> ids) {
        return EstateGoodsManageService.EstateGoodsManageRemove(ids);
    }

    @PostMapping("/edit")
    @ApiOperation(value = "地产商品管理编辑", notes = "地产商品管理")
    public Response goodsManageEdit(@RequestBody EstateGoodsManageDTO estateGoodsManageDTO) {
        return EstateGoodsManageService.EstateGoodsManageEdit(estateGoodsManageDTO);
    }

    @PostMapping("/query")
    @ApiOperation(value = "地产商品管理查询", notes = "地产商品管理")
    public Response goodsManageQuery(@RequestBody PageRequest<EstateGoodsManageDTO> query) {
        return EstateGoodsManageService.EstateGoodsManageQuery(query);
    }

    @PostMapping("/goods/queryGoodsByProject")
    @ApiOperation(value = "根据项目编码查询地产商品", notes = "地产商品管理")
    public Response queryGoodsByProject(@RequestParam String projectCode) {
        return EstateGoodsManageService.queryGoodsByProject(projectCode);
    }

    @GetMapping("/projectQuery")
    @ApiOperation(value = "项目查询", notes = "地产商品管理")
    public Response itemManageQuery() {
        return EstateGoodsManageService.getProject();
    }

    @GetMapping("/goods/queryAll")
    @ApiOperation(value = "商品查询", notes = "地产商品管理")
    public Response goodsManageQuery() {
        return EstateGoodsManageService.getGoods();
    }

    @GetMapping("/export")
    @ApiOperation(value = "地产商品管理导出", notes = "地产商品管理")
    public void estateGoodsManageExport(HttpServletRequest request, HttpServletResponse response) throws Exception {
        EstateGoodsManageService.estateGoodsManageExport(request, response);
    }

    @PostMapping("/import")
    @ApiOperation(value = "地产商品管理导入", notes = "地产商品管理")
    public Response goodsManageImport(@RequestParam("file") MultipartFile multipartFile){
        return EstateGoodsManageService.estateGoodsManageImport(multipartFile);
    }

}
